import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class one {
    public static void main(String[] args) throws IOException {
        String path = "E:" + File.separator + "test.txt";
        File file = new File(path);

        if (!file.exists()) file.createNewFile();

        OutputStream outputStream = null;
        try {
            String messenge = "Hi Hi Hi Hi";
            outputStream = new FileOutputStream(file, true);
            byte[] messenger = messenge.getBytes();
            for (byte by:messenger) {
                outputStream.write(by);
            }

        }catch (Exception e) {

        } finally {
            if (outputStream != null) {
                outputStream.close();
            }

        }
    }
}
